import request from '@/axios'
import { CurdData } from './types'

//用户管理 - 获取列表
export const getOperatorListApi = (params: any) => {
  return request.get({ url: '/admin/operator', params })
}

//用户管理 - 删除
export const deleteUserApi = (ids: string[] | number[]) => {
  return request.delete({ url: '/admin/operator', data: { ids } })
}

//用户管理 - 获取枚举
export const getEnumsApi = (params: any) => {
  return request.get({ url: '/admin/operator/fieldEnum', params })
}
//用户管理 - 回显
export const getBackShowApi = (params: any) => {
  return request.get({ url: '/admin/operator/detail', params })
}

//用户管理 - 获取部门枚举
export const getTreeSelectListApi = () => {
  return request.get({ url: '/admin/department/treeSelectOption' })
}

//用户管理 - 新增/编辑用户
export const saveApi = (data: Partial<CurdData>): Promise<IResponse> => {
  if (data.id) {
    return request.put({ url: '/admin/operator', data })
  } else {
    return request.post({ url: '/admin/operator', data })
  }
}
